<template>
<div>
	<yd-cell-group class="mt30" :title="name + '激活'">
        <yd-cell-item>
            <span slot="left">卡号：</span>
            <yd-input slot="right" required v-model="form.cardno" max="20" placeholder="请输入卡号"></yd-input>
        </yd-cell-item>
        <yd-cell-item>
            <span slot="left">卡密：</span>
            <yd-input slot="right" type="password" v-model="form.card_password" placeholder="请输入密码"></yd-input>
        </yd-cell-item>
        <yd-cell-item>
            <span slot="left">电话：</span>
            <yd-input slot="right" required v-model="form.mobile" max="20" placeholder="请输入激活电话"></yd-input>
        </yd-cell-item>

        <yd-cell-item>
            <span slot="left">备注：</span>
            <yd-textarea slot="right" maxlength="100" v-model="form.remark"></yd-textarea>
        </yd-cell-item>
    </yd-cell-group>

    <yd-button size="large" type="primary" @click.native="gogo">激活</yd-button>
</div>
</template>

<script>

import { mapGetters } from 'vuex';

export default {
	name: 'activation',
	
	data () {
		return {
		  	form : {
		  		cardno : '',
		  		card_password : '',
		  		mobile : '',
		  		remark : '',
		  	}
		}
	},

	components: {

		
	},

	computed : {
		...mapGetters([
			'company_code', 
		]),

		name () {
			return this.$route.query.name == undefined ? '' : this.$route.query.name;
		},
	},

	methods : {
		gogo () {

			if(this.form.cardno == ''){
				this.$dialog.toast({
                    mes: '请输入卡号',
                    timeout: 1500,
                    icon: 'error',
                });
                return;
			}

			if(this.form.card_password == ''){
				this.$dialog.toast({
                    mes: '请输入卡密',
                    timeout: 1500,
                    icon: 'error',
                });
                return;
			}

			if(this.form.mobile == ''){
				this.$dialog.toast({
                    mes: '请输入激活电话',
                    timeout: 1500,
                    icon: 'error',
                });
                return;
			}


			const para = {
				fun : 'activation',
				create_type : 'jihuo',
				from_app_id : 'qunmeng',
				mobile : this.form.mobile,
				cardno : this.form.cardno,
				card_password : this.form.card_password,
				remark : this.form.remark,
				cb : res => {
					this.$dialog.toast({
	                    mes: '激活成功',
	                    timeout: 1500,
	                    icon: 'success',
	                });
				},
				err : res => {
					this.$dialog.toast({
	                    mes: '激活失败 : ' + res,
	                    timeout: 1500,
	                    icon: 'error',
	                });
				}
			};

			this.$store.dispatch('update', para);
		},
	},

	watch:{
	    
	},

	mounted () {
		
		
	},

}
</script>

<style scoped>

</style>
